package com.uusee.crawler.xmlwriter;

import java.io.File;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.StopWatch;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.uusee.framework.bo.UniversalBo;
import com.uusee.shipshape.sp.model.Ugc;
import com.uusee.shipshape.zq.model.VideoReg;

public class VideoRegWriter {
	public static void main(String[] args) {
		try {
			ApplicationContext acx = new ClassPathXmlApplicationContext("spring/youku/applicationContext.xml");
			UniversalBo universalBo = (UniversalBo)acx.getBean("universalBo");
			
			
			VideoRegWriter writer = new VideoRegWriter();
			List<VideoReg> videoRegList = universalBo.getAll(VideoReg.class);
			for (VideoReg videoReg:videoRegList) {
				System.out.println(videoReg.getPageCode());
				writer.innerProcess(videoReg);
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static String createPropertyNode(String propertyName,String propertyValue,boolean cdata) {	
		StringBuffer nodesb = new StringBuffer();
		if ( StringUtils.isNotEmpty(propertyValue)) {
			nodesb.append(propertyName).append("=").append(propertyValue).append("\r\n");
		}
		return nodesb.toString();
	}
	public void innerProcess(VideoReg vr) {
		StringBuffer videoRegSb = new StringBuffer();
		videoRegSb.append(createPropertyNode("modelList",vr.getVideoListReg(),true));
		videoRegSb.append(createPropertyNode("model",vr.getVideoReg(),true));
		videoRegSb.append(createPropertyNode("playUrl",vr.getPlayUrlReg(),true));
		videoRegSb.append(createPropertyNode("title",vr.getOriginalTitleReg(),true));
		videoRegSb.append(createPropertyNode("logo",vr.getLogoReg(),true));
		videoRegSb.append(createPropertyNode("length",vr.getLengthReg(),true));
		videoRegSb.append(createPropertyNode("channel",vr.getCategoryReg(),true));
		videoRegSb.append(createPropertyNode("category",vr.getCategoryReg(),true));
		videoRegSb.append(createPropertyNode("tags",vr.getCategoryReg(),true));
		videoRegSb.append(createPropertyNode("summary",vr.getCategoryReg(),true));
		videoRegSb.append(createPropertyNode("vid",vr.getCategoryReg(),true));
		videoRegSb.append(createPropertyNode("evid",vr.getUploadUserIdReg(),true));
		videoRegSb.append(createPropertyNode("shareUrl",vr.getUploadUsernameReg(),true));
		videoRegSb.append(createPropertyNode("totalPageView",vr.getUploadUserBlogUrlReg(),true));
		videoRegSb.append(createPropertyNode("totalComment",vr.getUploadUserBlogUrlReg(),true));
		videoRegSb.append(createPropertyNode("totalFav",vr.getUploadUserBlogUrlReg(),true));
		videoRegSb.append(createPropertyNode("uploadUserid",vr.getUploadUserBlogUrlReg(),true));
		videoRegSb.append(createPropertyNode("uploadUsername",vr.getUploadUserBlogUrlReg(),true));
		videoRegSb.append(createPropertyNode("uploadUserblog",vr.getUploadUserBlogUrlReg(),true));
		videoRegSb.append(createPropertyNode("uploadDate",vr.getUploadUserBlogUrlReg(),true));
		System.out.println(videoRegSb);
	}
	
}
